﻿-- =============================================
-- Author:		Kevin Orbaker
-- Create date: 10/08/2007
-- Description:	Select alert history counts by application..
-- =============================================
CREATE PROCEDURE [dbo].[usp_select_AlertHistoryReportByApplication] 
	-- Add the parameters for the stored procedure here
	@ApplicationName varchar(256),
	@BeginDate datetime,
	@EndDate datetime
AS
BEGIN
	DECLARE @DateRange int

	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
   -- Insert statements for procedure here
	SELECT AlertHistory.[Application], count(*) as [Alerts]
	FROM AlertHistory, Fault
	WHERE AlertHistory.[Application] = @ApplicationName
	AND Fault.[DateTime] between @BeginDate and @EndDate
	AND Fault.FaultID = AlertHistory.FaultID
  group by  AlertHistory.[Application]
 
END
